#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2021/9/17 19:48
# @Author : lenovo
# @Email : 26541796406@qq.com
# @File : search_page.py
# @Project : mryx_test
"""搜索类"""
from appium.webdriver.common.mobileby import MobileBy as By
from page.base_page import BasePage
class SearchInput(BasePage):
    """搜索"""
    """定位器"""
    rearch_input_locator = (By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.' 
                             'FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.'
                             'LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.'
                             'LinearLayout/android.widget.LinearLayout/android.widget.TextView[2]')  # 搜索输入框
    keyword_input_locator = (By.ID,'cn.missfresh.application:id/search_view')   # 关键字输入框
    rearch_button_locator = (By.ID,'cn.missfresh.application:id/tv_search')  # 搜索按钮
    cat_all_locator = (By.ID,'cn.missfresh.application:id/hot_sale_sub_title')  # 查看全部
    get_text_locator = (By.ID,'cn.missfresh.application:id/tv_product_name') # 获取搜索内容文本信息
    # 具体操作
    def click_reach_input(self):
        """点击搜索框"""
        self.driver.find_element(*self.rearch_input_locator).click()
    def click_keyword(self):
        """点击关键字输入框"""
        self.driver.find_element(*self.keyword_input_locator).click()
    def input_keyword(self,keyword):
        """输入关键字"""
        self.driver.find_element(*self.keyword_input_locator).send_keys(keyword)
    def click_butto(self):
        """点击搜索"""
        self.driver.find_element(*self.rearch_button_locator).click()
    def click_cat(self):
        """点击查看全部"""
        self.driver.find_element(*self.cat_all_locator).click()
    def get_crucian_text(self):
        """获得口碑文本"""
        return self.driver.find_element(*self.get_text_locator).text